package com.study.spring.ch04;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping(value="/ch04") //①处理器的通用映射前缀
public class HelloWorldController {

	/**
	 * /ch04/hello?phoneNum=010-12345678
	 * @param phoneNum
	 * @return
	 * @throws Exception
	 */
	
	@RequestMapping(value = "/hello") //②相对于①处的映射进行窄化
	public ModelAndView handleRequest(@ModelAttribute PhoneNumberModel phoneNum) 
			throws Exception {
		
		ModelAndView mv=new ModelAndView();
		mv.addObject("message", "areacode:" +phoneNum.getAreaCode() 
			+ ";phoneNum："+phoneNum.getPhoneNumber());
		mv.setViewName("ch03/hello");
		return mv;
	}
	
}
